package model

import (
	"gorm.io/gorm/clause"
	"server/common"
	"server/pkg/app"
)

type Log struct {
	Model
	Name   string `json:"name"`
	IP     string `json:"ip"`
	DESC   string `json:"desc"`
	People string `json:"people"`
}

func (log *Log) List(page *app.Page) ([]Log, int64) {
	log_list := []Log{}
	var count int64
	if err := common.DB.Preload(clause.Associations).Order("id desc").Limit(page.Size).Offset((page.Page - 1) * page.Size).Find(&log_list).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
		return log_list, count
	}
	return log_list, count
}
